package com.itheima.service.impl;

import com.itheima.dao.UserDao;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

//@Component("userService")
@Service("userService")
@Scope
public class UserServiceImpl implements UserService {
    @Autowired      //引用类型，按照类型注入
    @Qualifier("userDao")   //辅助Autowired，指定注入Bean的id
    private UserDao userDao;

    @Value("12312")  //基本类型数据的注入
    private int num;

    public void save() {
        System.out.println("user service running..." + num + " " + userDao);
    }

    @PostConstruct
    public void init(){
        System.out.println("user servier init...");
    }

    @PreDestroy
    public void destroy(){
        System.out.println("user servier destroy...");
    }

}
